import json

def generate_configs():
    # Read configuration from JSON file
    with open('./config.json', 'r') as f:
        config = json.load(f)
    
    shape = config['shape']
    dtype = config['dtype']
    
    # Generate C++ header file
    with open('../shape_config.h', 'w') as f:
        f.write(f'#ifndef SHAPE_CONFIG_H\n')
        f.write(f'#define SHAPE_CONFIG_H\n\n')
        f.write(f'const int SHAPE[] = {{{shape[0]}, {shape[1]}}};\n')
        f.write(f'const int SHAPE_SIZE = {len(shape)};\n\n')
        f.write(f'#endif // SHAPE_CONFIG_H\n')
    
    # Generate Python config file
    with open('./shape_config.py', 'w') as f:
        f.write(f'SHAPE = {shape}\n')
        f.write(f'DTYPE = "{dtype}"\n')

generate_configs()
